const Controller = require("../controllers/common");

const documentation = require("../schema/common");

const { checkAuth } = require("../utils/checkAuth");

const { upload } = require("./../index");

const routes = [
  // {
  //   method: "POST",
  //   url: "/WXminLogin",
  //   handler: Controller.WXminLogin,
  //   config: {
  //     tag: "common",
  //   },
  //   schema: documentation.WXminLoginSchema,
  // },
  {
    method: "POST",
    url: "/Login",
    handler: Controller.Login,
    config: {
      tag: "common",
    },
    schema: documentation.LoginSchema,
  },
  {
    method: "POST",
    url: "/PhoneLogin",
    handler: Controller.PhoneLogin,
    config: {
      tag: "common",
    },
    schema: documentation.PhoneLoginSchema,
  },
  {
    method: "POST",
    url: "/Registration",
    handler: Controller.Registration,
    config: {
      tag: "common",
    },
    schema: documentation.RegistrationSchema,
  },
  {
    method: "DELETE",
    url: "/Unsubscribe",
    preHandler: [checkAuth],
    handler: Controller.Unsubscribe,
    config: {
      tag: "common",
    },
    schema: documentation.UnsubscribeSchema,
  },
  {
    method: "GET",
    url: "/LoginOut",
    handler: Controller.LoginOut,
    config: {
      tag: "common",
    },
    schema: documentation.LoginOutSchema,
  },
  {
    method: "PUT",
    url: "/RetrievePassword",
    handler: Controller.RetrievePassword,
    config: {
      tag: "common",
    },
    schema: documentation.RetrievePasswordSchema,
  },
  {
    method: "POST",
    url: "/SMScode",
    handler: Controller.SMScode,
    config: {
      tag: "common",
    },
    schema: documentation.SMScodeSchema,
  },
  {
    method: "PUT",
    url: "/Bundled",
    handler: Controller.Bundled,
    config: {
      tag: "common",
    },
    schema: documentation.BundledSchema,
  },
  {
    method: "GET",
    url: "/UserInfo",
    handler: Controller.UserInfo,
    config: {
      tag: "common",
    },
    schema: documentation.UserInfoSchema,
  },
  {
    method: "POST",
    url: "/RoleInfo",
    handler: Controller.RoleInfoPOST,
    config: {
      tag: "common",
    },
    schema: documentation.POSTRoleInfoSchema,
  },
  {
    method: "DELETE",
    url: "/RoleInfo/:roleId",
    handler: Controller.RoleInfoDELETE,
    config: {
      tag: "common",
    },
    schema: documentation.DELETERoleInfoSchema,
  },
  {
    method: "PUT",
    url: "/RoleInfo/:roleId",
    handler: Controller.RoleInfoPUT,
    config: {
      tag: "common",
    },
    schema: documentation.PUTRoleInfoSchema,
  },
  {
    method: "GET",
    url: "/RoleInfo",
    handler: Controller.RoleInfoGET,
    config: {
      tag: "common",
    },
    schema: documentation.GETRoleInfoSchema,
  },
  {
    method: "GET",
    url: "/Allapi",
    handler: Controller.Allapi,
    config: {
      tag: "common",
    },
    schema: documentation.AllapiSchema,
  },
  {
    method: "POST",
    url: "/Bindrole",
    handler: Controller.Bindrole,
    config: {
      tag: "common",
    },
    schema: documentation.BindroleSchema,
  },

  {
    method: "GET",
    url: "/QrcodeInfo",
    handler: Controller.QrcodeInfo,
    config: {
      tag: "common",
    },
    schema: documentation.GETQrcodeInfoSchema,
  },
  {
    method: "POST",
    url: "/QrcodeInfo",
    preHandler: upload.single("photoUrls"),
    handler: Controller.QrcodeInfoPOST,
    config: {
      tag: "common",
    },
    schema: documentation.POSTQrcodeInfoSchema,
  },
  {
    method: "PUT",
    url: "/QrcodeInfo/:Id",
    handler: Controller.QrcodeInfo,
    config: {
      tag: "common",
    },
    schema: documentation.PUTQrcodeInfoSchema,
  },
  {
    method: "DELETE",
    url: "/QrcodeInfo/:Id",
    handler: Controller.QrcodeInfo,
    config: {
      tag: "common",
    },
    schema: documentation.DELETEQrcodeInfoSchema,
  },
  {
    method: "GET",
    url: "/QrcodeInfo/:id",
    handler: Controller.QrcodeInfoID,
    config: {
      tag: "common",
    },
    schema: documentation.GETIDQrcodeInfoSchema,
  },
];

module.exports = routes;
